package feedback;

import java.rmi.RemoteException;

import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
import javax.ejb.SessionContext;

import user.User;
import descriptor.FeedbackDescriptor;

/**
 * FeedbackBean
 * 
 * 
 * The FeedbackBean class implements all the methods that a remote client expect to find
 * when it calls the interface (Feedback).
 * 
 * Note :  -We use @SuppressWarnings("unchecked") to avoid the useless warnings
 */
@SuppressWarnings("unchecked")
public abstract class FeedbackBean implements EntityBean{
	
	// <ATTRIBUTES>
	
	// simple attributes
	public abstract int getId();
	public abstract void setId(int id);
	
	public abstract String getName();
	public abstract void setName(String name);
	
	public abstract String getInfos();
	public abstract void setInfos(String infos);
	
	public abstract User getAuthor();
	public abstract void setAuthor(User user);
	
	// </ATTRIBUTES>
	public FeedbackDescriptor getDescriptor(){
		return new FeedbackDescriptor(getId(),getName(),getInfos(),getAuthor().getId(),getAuthor().getName()+" "+getAuthor().getFirstName());
	}
	// <BEANS METHODS>
	
	public String ejbCreate(String name, String infos, User author) throws CreateException {
		setName(name);
		setInfos(infos);
		return null;
	}

	
	public void ejbPostCreate(String name, String infos, User author){
		setAuthor(author);
	}
	
	public void ejbActivate() throws EJBException, RemoteException {}
	public void ejbPassivate() throws EJBException, RemoteException {}
	public void ejbRemove() throws EJBException, RemoteException,RemoveException {}
	public void setSessionContext(SessionContext arg0) throws EJBException, RemoteException {}
	public void ejbLoad() throws EJBException, RemoteException {}
	public void ejbStore() throws EJBException, RemoteException {}
	public void setEntityContext(EntityContext arg0) throws EJBException, RemoteException {}
	public void unsetEntityContext() throws EJBException, RemoteException {}
	
	// </ BEANS METHODS>

}
